package com.bwie.controller;

import com.bwie.pojo.TbUser;
import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.AdminData;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Wrj
 * @Date: 2025/4/22 10:15
 * @Description:
 **/
@RestController
@RequestMapping("/user/index")
public class IndexController {


    @Autowired
    TbUserService tbUserService;

    @PostMapping("/getUserlistByid/{id}")
    public R getUserlistByid(@PathVariable(name = "id") Integer id){


        return tbUserService.getUserlistByid(id);
    }

    /**
     * 用户登录
     * @param adminData
     * @return
     */
    @PostMapping("/AdminLogin")
    public R AdminLogin(@RequestBody AdminData adminData){

        return tbUserService.AdminLogin(adminData);

    }


    @PostMapping("/userList")
    public R userList(@RequestBody PageInfoVo pageInfoVo){

        return tbUserService.userList(pageInfoVo);
    }


    @PostMapping("/userReg")
    public R userReg(@RequestBody @Validated TbUser tbUser){

        return tbUserService.userReg(tbUser);
    }


    @PostMapping("/checkUser")
    public R checkUser(@RequestBody TbUser tbUser){

        return tbUserService.checkUser(tbUser);

    }

    @PostMapping("/getMyInfo")
    public R getMyInfo(){
        return tbUserService.getMyInfo();
    }

    @PostMapping("/updateUser")
    public R updateUser(@RequestBody TbUser tbUser){
        return tbUserService.updateUser(tbUser);
    }
}
